﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="UserManager.aspx.cs"
    Inherits="MobileManager.UserManager" Title="用户管理" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .tdInfo
        {
            text-align: left;
            height: 40px;
            font-size: 12px;
        }
        .txtInfo
        {
            width: 100px;
            height: 20px;
            background-color: White;
            border-style: none;
            border: solid 1px #9999CC;
        }
        .divLeft
        {
            width: 165px;
            list-style: none;
            margin-left: 10px;
            margin-right: 5px;
            margin-top: 20px;
            float: left;
        }
        .divRight
        {
            float: left;
            margin-top: 10px;
            margin-right: 10px;
        }
    </style>
    <script type="text/javascript">
        function CheckPD() {
            var strPD2 = $("#<%=txtNewPassWord2.ClientID%>").val().Trim();
            var strPD1 = $("#<%=txtNewPassWord1.ClientID%>").val().Trim();
            if (strPD1 != "" && strPD2 != "") {
                if (strPD2 != strPD1) {
                    document.getElementById("spanMessage").innerHTML = "两次密码输入不一致！";
                    document.getElementById("<%=btnSubmit.ClientID%>").disabled = "disabled";
                }
                else {
                    document.getElementById("spanMessage").innerHTML = "";
                    document.getElementById("<%=btnSubmit.ClientID%>").disabled = "";
                }
            }
        }
        function CheckSave() {
            var strUserID = $("#<%=txtUserID.ClientID%>").val().Trim();
            if (strUserID == "") {
                document.getElementById("spanMessage").innerHTML = "用户名不能为空！";
                return false;
            }
            var strPD1 = $("#<%=txtNewPassWord1.ClientID%>").val().Trim();
            if (strPD1 == "") {
                document.getElementById("spanMessage").innerHTML = "密码不能为空！";
                return false;
            }
            var strPD2 = $("#<%=txtNewPassWord2.ClientID%>").val().Trim();
            if (strPD2 == "") {
                document.getElementById("spanMessage").innerHTML = "确认密码不能为空！";
                return false;
            }
            var strName = $("#<%=txtUserName.ClientID%>").val().Trim();
            if (strName == "") {
                document.getElementById("spanMessage").innerHTML = "姓名不能为空！";
                return false;
            }
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <form runat="server">
    <div style="width: 100%" align="center">
        <div class="divRight" style="text-align: center;">
            <div style="width: 100%; text-align: center; margin-top: 10px; font-size: 12px;"
                id="divAdd" runat="server">
                <table>
                    <tr>
                        <td colspan="2" style="text-align: center;">
                            <span id="spanMessage" style="font-size: 12px; color: Red;"></span>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            用户名：
                        </td>
                        <td class="tdInfo" style="width: 320px;">
                            <asp:TextBox ID="txtUserID" runat="server" MaxLength="50" Width="200px" CssClass="txtBoxNormal"></asp:TextBox><span
                                style="color: Red;">设定后不可修改! </span>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            密码：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtNewPassWord1" runat="server" Width="200px" MaxLength="50" onblur="CheckPD()"
                                TextMode="Password" CssClass="txtBoxNormal"></asp:TextBox><span style="color: Red;">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            确认密码：
                        </td>
                        <td class="tdInfo">
                            <asp:TextBox ID="txtNewPassWord2" runat="server" Width="200px" MaxLength="50" onblur="CheckPD()"
                                TextMode="Password" CssClass="txtBoxNormal"></asp:TextBox><span style="color: Red;">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            姓名：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtUserName" runat="server" Width="200px" CssClass="txtBoxNormal"></asp:TextBox><span
                                style="color: Red;">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            角色：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:DropDownList ID="ddlRole" runat="server">
                                <asp:ListItem Value="1" Text="系统管理员"></asp:ListItem>
                                <asp:ListItem Value="2" Text="系统用户" Selected="True"></asp:ListItem>
                                <asp:ListItem Value="3" Text="客户"></asp:ListItem>
                                <asp:ListItem Value="4" Text="受限用户"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            固定电话：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtTelephone" runat="server" Width="200px" CssClass="txtBoxNormal"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            手机：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtMobile" runat="server" Width="200px" CssClass="txtBoxNormal"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            地址：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtAddress" runat="server" Width="200px" CssClass="txtBoxNormal"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            备注：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtRemark" runat="server" Width="200px" CssClass="txtBoxNormal"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            数据显示比例：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtDataRate" runat="server" Width="200px" CssClass="txtBoxNormal"
                                MaxLength="10"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            客户编号：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtCustomerNO" runat="server" Width="200px" Height="100px" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdInfo">
                            通道号码：
                        </td>
                        <td class="tdInfo" style="width: 250px;">
                            <asp:TextBox ID="txtChanelNO" runat="server" Width="200px" Height="100px" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: center;" colspan="2">
                            <asp:Button ID="btnSubmit" runat="server" Text="增 加" CssClass="button_blue" OnClick="btnSubmit_Click"
                                OnClientClick="return CheckSave();" />&nbsp;&nbsp;
                            <asp:Button ID="btnCancel" runat="server" Text="取 消" CssClass="button_gray" OnClick="btnCancel_Click" />
                        </td>
                    </tr>
                </table>
            </div>
            <div id="divGV" runat="server" style="margin-top: 10px;">
                <asp:Button ID="btnADD" runat="server" Text="添加用户" CssClass="button_blue" OnClick="btnADD_Click" />
                <br />
                <br />
                <asp:GridView ID="GVinfo" runat="server" AutoGenerateColumns="False" CssClass="reason_box"
                    Font-Size="12px" CellPadding="0" BorderWidth="0px" BorderColor="#A6E1FF" Width="100%"
                    OnRowDataBound="GVinfo_RowDataBound" OnRowCancelingEdit="GVinfo_RowCancelingEdit"
                    OnRowDeleting="GVinfo_RowDeleting" OnRowEditing="GVinfo_RowEditing" OnRowUpdating="GVinfo_RowUpdating">
                    <Columns>
                        <asp:TemplateField HeaderText="用户名">
                            <ItemTemplate>
                                <asp:Label ID="lbTarget" runat="server" Text='<%# Bind("UserID") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                            <ItemStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="密码">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtPD" runat="server" MaxLength="50" CssClass="txtInfo"></asp:TextBox>
                                <asp:HiddenField ID="hdfPD" runat="server" Value='<%#Eval("PassWordinfo") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lbPD" runat="server"></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                            <ItemStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="姓名">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtUserName" runat="server" Text='<%# Bind("UserName") %>' MaxLength="50"
                                    CssClass="txtInfo"></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lbUserName" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                            <ItemStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="角色">
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlRole" runat="server">
                                    <asp:ListItem Value="1" Text="系统管理员"></asp:ListItem>
                                    <asp:ListItem Value="2" Text="系统用户"></asp:ListItem>
                                    <asp:ListItem Value="3" Text="客户"></asp:ListItem>
                                    <asp:ListItem Value="4" Text="受限用户"></asp:ListItem>
                                </asp:DropDownList>
                                <asp:HiddenField ID="hdfRoleID" runat="server" Value='<%#Eval("RoleID") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lbRole" runat="server"></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                            <ItemStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="手机">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtMobile" runat="server" Text='<%# Bind("Mobile") %>' MaxLength="50"
                                    CssClass="txtInfo"></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lbMobile" runat="server" Text='<%# Bind("Mobile") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                            <ItemStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="客户编号">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtCustomerNO" runat="server" Text='<%# Bind("CustomerNO") %>' TextMode="MultiLine"
                                    Height="80px" CssClass="txtInfo"></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lbCustomerNO" runat="server" Text='<%# Bind("CustomerNO") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                            <ItemStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="通道号码">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtChanelNO" runat="server" Text='<%# Bind("ChanelNO") %>' TextMode="MultiLine"
                                    Height="80px" CssClass="txtInfo"></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lbChanelNO" runat="server" Text='<%# Bind("ChanelNO") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                            <ItemStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="管理" ItemStyle-Wrap="false">
                            <EditItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                    Text="更新"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Text="取消"></asp:LinkButton><asp:HiddenField ID="HF1" runat="server" Value='<%#Eval("ID") %>' />
                                <asp:HiddenField ID="hdfUserID" runat="server" Value='<%#Eval("UserID") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                    Text="编辑"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
                                    Text="删除" OnClientClick="return confirm('确定要删除？')"></asp:LinkButton><asp:HiddenField
                                        ID="HF2" runat="server" Value='<%#Eval("ID") %>' />
                                <asp:HiddenField ID="hdfUserID" runat="server" Value='<%#Eval("UserID") %>' />
                                <asp:HiddenField ID="hdfRoleID" runat="server" Value='<%#Eval("RoleID") %>' />
                            </ItemTemplate>
                            <HeaderStyle BorderColor="#4DA6FF" BorderWidth="1px" />
                            <ItemStyle BorderColor="#4DA6FF" BorderWidth="1px" Width="80px" />
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <span style="color: Red; font-weight: bold;">无数据显示</span>
                    </EmptyDataTemplate>
                </asp:GridView>
            </div>
        </div>
    </div>
    </form>
</asp:Content>
